<!DOCTYPE html>
  <html>
  <head>
      <meta charset="utf-8">
      <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
      <title>title</title>
      <link rel="stylesheet" type="text/css" href="../../css/api.css"/>
            <link rel="stylesheet" type="text/css" href="../../css/aui.css" />
      <style>
      *{margin: 0; padding: 0;font-family: "微软雅黑";}
      #header { background: #fff; height:50px;}
    .aui-bar-nav{background-color: #fff;position: relative;}
    .aui-btn.aui-pull-left{ background: #FFF}
    .aui-btn.aui-pull-left span{color: #333}
      .aui-bar-nav .aui-btn .aui-iconfont,.aui-bar-nav .aui-title{color: #333}
      body{background-color: #fff}
    .logo {margin-top: 100px;margin-bottom: 29px;}
    .logo img{display: block;;width:65px;height: 65px;display:block;margin: 0 auto;}
    .register_main{width: 100%;box-sizing: border-box;padding: 0 15px;margin-bottom: 33px;}
    .register_main input{height: 60px;line-height: 45px;padding-top: 15px;display:block;box-sizing: border-box;font-size: 13px;color: #A9A9A9;padding-left:24px;;width: 100%;background-repeat: no-repeat;background-position:left 29px;border-bottom: 1px solid #dedede}
    .register_main #phone{background-image: url(../../image/phone.svg);background-size: 12px 16px;background-position: 1px 29px; }
    .register_main #yzm{background-image: url(../../image/yzm.svg);background-size: 14px 16px;}
    .register_main #password1{background-image: url(../../image/password.svg);background-size: 13px 16px;}
    .register_main #password2{background-image: url(../../image/password.svg);background-size: 13px 16px;}
    #top { position:relative;}
    #fasong{ background:#fc8622; font-size: 12px; color: #FFF; position: absolute; right: 0; top: 18px; }
    #fasong1{ background:#A9A9A9; font-size: 12px; color: #FFF; position: absolute; right: 0; top: 18px; display: none}
    .register_main input::-webkit-input-placeholder {color:#A9A9A9;font-size: 13px;}
    .register_main input::-moz-placeholder{color:#A9A9A9;font-size: 13px;}
    .register_main input:-moz-placeholder {color:#A9A9A9;font-size: 13px;}
    .register_main input:-ms-input-placeholder {color:#A9A9A9;font-size: 13px;}
    .register_main input[type=submit]{border:none;padding-top: 0;padding-left: 0;width: 100%;box-sizing: border-box;height: 38px;color: #fff;text-align: center;line-height: 38px;font-size: 13px;background-color: #fc8622;margin-top: 38px;display: block;-webkit-appearance: none;
    }
      .register_bottom span{font-size: 12px;color: #B7B7B7;text-align: center;display: block;}
      .zhengce{text-align: center; font-size: 14px; margin-top: 80px;}
      .zhengce>a{color: #fc8622;}
      #yinshi{vertical-align:middle}
      </style>
  </head>
  <body>
    <header id="header">
      <a class="aui-btn aui-pull-left" tapmode onclick="api.closeWin()">
          <span class="aui-iconfont aui-icon-left" style="font-size:14px;"></span>
      </a>
    </header>
    <section>
      <div class="logo">
        <img src="../../image/logo.png" alt="">
      </div>
    <div class="register_main">
          <!-- <input id="username" class="input" type="text" placeholder="请输入用户名"> -->
          <div id="top">
          <button id="fasong" onclick="fdx()">点击发送验证码</button>
          <button id="fasong1"></button>
          <input id="phone" class="input" type="number" placeholder="请输入手机号">
          </div>

          <input id="yzm" class="input" type="tel" placeholder="请输入验证码">
          <input id="password1" class="input" type="password" placeholder="请输入密码">
          <input id="password2" class="input" type="password" placeholder="确认密码">
          <input tapmode onclick="zhuche()" type="submit" value="注册">
    </div>
        <div class="register_bottom">
          <span class="le" onclick="api.closeWin();">已有账号，立即登录</span>
        </div>


        <div class="zhengce">
          <input type="checkbox" id="yinshi" value="《隐私政策》" ><a tapmode onclick="zhengce()">《用户协议及隐私政策》</a>
        </div>
    </section>
  </body>
  <script type="text/javascript" src="../../script/api.js"></script>
    <script type="text/javascript" src="../../script/public.js"></script>
  <script type="text/javascript">
  apiready = function() {

  };

var phone,phone,password1,password2,password1Value,password2Value,sjs,invl,time;
  function zhuche() {
  yinshi = $api.byId('yinshi');
  if(!$api.byId('yinshi').checked){
    api.toast({
        msg: '请勾选隐私政策',
        duration: 2000,
        location: 'bottom'

    });
    return;
  }
    phone = $api.byId('phone');
    password1 = $api.byId('password1');
    password2 = $api.byId('password2');
    phoneValue = $api.val(phone);
    password1Value = $api.val(password1);
    password2Value = $api.val(password2);

if(phoneValue==""&&password1Value==""){
  // api.toast({
  //     msg: '密码未填',
  //     duration: 2000,
  //     location: 'bottom'
  // });
xuehua("密码未填写",2000)
}
console.log(sjs);
var yanzhengxia = $api.val($api.byId("yzm"));
    if(sjs == yanzhengxia){

      api.ajax({
          url: $api.getStorage("backapi")+'/index.php?s=member&c=register&m=ajax',
          method: 'post',
          data:{
            values:{
                    username:phoneValue,
                    phone:phoneValue,
                    password:password1Value,
                    password2:password1Value,
                  }
              }
        },function(ret, err){
          console.log(JSON.stringify(ret));
          if (ret.return) {
                $api.setStorage('sys',ret.id);
               $api.setStorage('member', ret.uid);
               api.showProgress({
                   style: 'default',
                   animationType: 'fade',
                   title: '注册成功',
                   text: '请稍后...',
                   modal: false
               });
               var jsfun = 'dingshi();';
                 api.execScript({
                   frameName: 'index',
                   script: jsfun
                });

                 api.closeWin({
                     name: 'login'
                 });
                 api.closeWin();

          } else {
              xuehua(ret.msg,2000)
              // api.toast({
              //     msg: ret.msg,
              //     duration: 2000,
              //     location: 'bottom'
              // });

          }
      });

    }else{
      xuehua("验证码错误",2000)
      // api.toast({
      //     msg: '验证码错误',
      //     duration: 2000,
      //     location: 'bottom'
      // });

    }


  }

function fdx(){
        time = 60;
     phoneValue = $api.val($api.byId('phone'));
     var data=[];

     if(phoneValue){

       sjs = Math.floor(Math.random()*10).toString()+Math.floor(Math.random()*10).toString()+Math.floor(Math.random()*10).toString()+Math.floor(Math.random()*10).toString()
       data["content"] = phoneValue;
       data["mobile"] =sjs;
       api.ajax({
           url: $api.getStorage("backapi")+'/index.php?c=home&m=ajaxsend',
           method: 'post',
           data: {
               values: {
                   content:sjs,
                   mobile:phoneValue,
               }
           }
       },function(ret, err){
           if (ret.status==1) {
             xuehua('发送成功',2000)
            //  api.toast({
            //      msg: '发送成功',
            //      duration: 2000,
            //      location: 'bottom'
            //  });
             ttime()
             invl = setInterval("ttime()",1000);
              $api.css($api.byId('fasong'),'display:none');
              $api.css($api.byId('fasong1'),'display:block');

            //  console.log(JSON.stringify(ret));
          } else if(ret.code=='c'){
              xuehua('该账号已经注册',2000)
              setTimeout(function(){api.closeWin()},2000)
          }else{
            console.log("cuowu")
            xuehua('请输入正确的手机号',2000)
            // api.toast({
            //     msg: '请输入正确的手机号',
            //     duration: 2000,
            //     location: 'bottom'
            // });
            console.log(JSON.stringify(ret));
            console.log($api.getStorage("backapi"))

          }

       });

     }else{
       xuehua('请输入手机号',2000)
      //  api.toast({
      //      msg: '请输入手机号',
      //      duration: 2000,
      //      location: 'bottom'
      //  });

     }

}


function ttime(){
   $api.text($api.byId('fasong1'),time+"s后可重新发送");
   if(time==0){
    $api.css($api.byId('fasong1'),'display:none');
    $api.css($api.byId('fasong'),'display:block');
     clearInterval(invl);
   }
   time--;

}

function zhengce(){
  api.openWin({
  name: 'zhengce',
  url: 'yinshi_win.html',
  pageParam: {
      name: 'test'
  }
});
}

  </script>
  </html>
